###############################################################################
#
# Øving 1 UCSysDes Makefile
#
###############################################################################

# assembler
AS = avr32-as
# assembleropsjoner
ASFLAGS = -gstabs

# C-compiler
CC = avr32-gcc
# compiler options
CCFLAGS = -Wall -g -c

# linker (gcc is used, see descrition)
LD = avr32-gcc
# linking options (-lm links in the math library)
LDFLAGS = -lm 

# flashprogrammerer
AVR32PROGRAM = avr32program

###############################################################################
# make-regler

# link: lag ELF fra objektfiler
oeving2.elf: oeving2.o
	$(LD) $^ $(LDFLAGS)  -o $@

# assembly: lag objektfil fra assemblyfil
oeving2.o: oeving2.c oeving2.h
	$(CC) $(CCFLAGS) -o $@ $<

# last opp til STK1000 (programmere flash)
.PHONY : upload
upload : oeving2.elf
	$(AVR32PROGRAM) halt
	sleep 3
	$(AVR32PROGRAM) program -e -f0,8Mb $<

# fjern alle autogenererte filer
.PHONY : clean
clean :
	rm -rf *.o *.elf
